From 44631ace40ea0335a0da669a0f0651a171a46a5a Mon Sep 17 00:00:00 2001 From: "danms@us.ibm.com" Date: Tue, 15 Nov 2005 16:07:44 +0100 Subject: [PATCH] Reduce the time required to start xm-test domains by allowing the console to retry connecting to the DomU multiple times. A polling approach instead of a wait-and-hope-it-works approach. --- tools/xm-test/lib/XmTestLib/Console.py | 33 ++++++++++++++++-------- tools/xm-test/lib/XmTestLib/XenDomain.py | 2 +- 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/tools/xm-test/lib/XmTestLib/Console.py b/tools/xm-test/lib/XmTestLib/Console.py index 0e34bcf5c8..3c5691dc96 100755 --- a/tools/xm-test/lib/XmTestLib/Console.py +++ b/tools/xm-test/lib/XmTestLib/Console.py @@ -62,26 +62,37 @@ class XmConsole: self.historySaveCmds = historySaveCmds self.debugMe = False self.limit = None + self.delay = 2 consoleCmd = ["/usr/sbin/xm", "xm", "console", domain] - if verbose: - print "Console executing: " + str(consoleCmd) + start = time.time() + + while (time.time() - start) < self.TIMEOUT: + if verbose: + print "Console executing: %s" % str(consoleCmd) - pid, fd = pty.fork() + pid, fd = pty.fork() - if pid == 0: - os.execvp("/usr/sbin/xm", consoleCmd[1:]) + if pid == 0: + os.execvp("/usr/sbin/xm", consoleCmd[1:]) - self.consolePid = pid - self.consoleFd = fd + self.consolePid = pid + self.consoleFd = fd - tty.setraw(self.consoleFd, termios.TCSANOW) + tty.setraw(self.consoleFd, termios.TCSANOW) - bytes = self.__chewall(self.consoleFd) - if bytes < 0: - raise ConsoleError("Console didn't respond") + bytes = self.__chewall(self.consoleFd) + + if bytes > 0: + return + if verbose: + print "Console didn't attach, waiting %i sec..." % self.delay + time.sleep(self.delay) + + raise ConsoleError("Console didn't respond after %i secs" % self.TIMEOUT) + def __addToHistory(self, line): self.historyBuffer.append(line) self.historyLines += 1 diff --git a/tools/xm-test/lib/XmTestLib/XenDomain.py b/tools/xm-test/lib/XmTestLib/XenDomain.py index 6a8145ee84..7bacf2b683 100644 --- a/tools/xm-test/lib/XmTestLib/XenDomain.py +++ b/tools/xm-test/lib/XmTestLib/XenDomain.py @@ -228,7 +228,7 @@ class XmTestDomain(XenDomain): # status, output = traceCommand("xm list") XenDomain.start(self) - waitForBoot() +# waitForBoot() def startNow(self): XenDomain.start(self) -- 2.30.2